home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / T U R B O Language / Turbo C Tools v6.0 / EXAMPLES / DEMOEDT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.8 KB  |  63 lines

  1. /**
  2. *    DEMOEDT.C    Simple example of Turbo C TOOLS edit function
  3. *            usage.
  4. *
  5. *  Version    6.00 (C)Copyright Blaise Computing Inc. 1987, 1989
  6. *
  7. **/
  8.  
  9.  
  10. #include <bedit.h>
  11. #include <bstrings.h>
  12. #include <stdio.h>
  13.  
  14. #define FIELD_WIDTH    30
  15. #define FIELD_HEIGHT    5
  16.  
  17. void main(void);
  18. char returned_string[FIELD_WIDTH * FIELD_HEIGHT + 1];
  19.  
  20. void main()
  21. {
  22.     int         error_code;
  23.     ED_CONTROL        field_control;
  24.     int         cursor_was_off,row,col,high,low;
  25.     char       *pinitial_string =
  26.     "This is a demonstration of the Turbo C TOOLS edit functions.";
  27.     KEY_SEQUENCE    final_key;
  28.  
  29.     cursor_was_off = sccurst(&row,&col,&high,&low);
  30.  
  31.     field_control.ul_corner.row       = 0;
  32.     field_control.ul_corner.col       = 0;
  33.     field_control.dimensions.h          = FIELD_HEIGHT;
  34.     field_control.dimensions.w          = FIELD_WIDTH;
  35.     field_control.attribute          = 0x0007;   /* Reverse video. */
  36.     field_control.replace_cursor.high = 6;      /* Underline        */
  37.     field_control.replace_cursor.low  = 7;      /*   cursor.        */
  38.     field_control.insert_cursor.high  = 0;      /* Solid cursor.  */
  39.     field_control.insert_cursor.low   = 7;
  40.     field_control.control_function    = (PKEY_CONTROL) NIL;
  41.     field_control.control_flags       = 0;
  42.  
  43.     scpclr();
  44.  
  45.     error_code = edfield(pinitial_string, returned_string,
  46.              sizeof(returned_string),
  47.              &field_control, &final_key);
  48.  
  49.     sccurset(FIELD_HEIGHT + 1, 0);
  50.     scpgcur(cursor_was_off, high, low, CUR_NO_ADJUST);
  51.  
  52.     if ((error_code != ED_NO_ERROR) && (error_code != ED_USER_ABORT))
  53.     {
  54.     printf("Error %d editing.\n", error_code);
  55.     exit(-1);
  56.     }
  57.  
  58.     printf("Final key: char %02x, key %02x.\n",
  59.        final_key.character_code, final_key.key_code);
  60.  
  61.     printf("Returned string:\n\"%s\"\n", returned_string);
  62. }
  63.